class TaskQueue(object):
    def __init__(self):
        self.__list = []

    def put(self, task_worker):
        self.__list.append(task_worker)

    def pop(self):
        if self.is_empty():
            return None;
        return self.__list.pop(0)

    def get_length(self):
        if self.is_empty():
            return 0
        else:
            return len(self.__list)

    def is_empty(self):
        """
        判断列表是否为空
        :return:
        """
        return self.__list == []

    def delete(self, index):
        if self.is_empty():
            return False
        if (index >= 0) and (index < self.get_length()):
            self.__list.pop(index)
            return True
        else:
            return False

    def get_item(self, index):
        if index < 0:
            return None
        if index > len(self.__list) - 1:
            return None
        return self.__list[index]

    def set_item(self, index, task_worker):
        if index < 0:
            return None
        if index > len(self.__list) - 1:
            return None
        self.__list[index] = task_worker
        return True

    def get_list(self):
        return self.__list

